package com.ideyatech.errorhandling.editor;

import java.beans.PropertyEditorSupport;

import com.ideyatech.errorhandling.entity.User;

public class UserEditor extends PropertyEditorSupport {

	@Override
	public String getAsText(){
		Object user = getValue();
		if(user==null){
			return "";
		}
		return ((User)user).getId().toString();
	}
	
	@Override
	public void setAsText(String text) throws IllegalArgumentException{
		Long id = Long.parseLong(text);
		setValue(id);
	}
}
